在WSL启用ssh | 您所在的位置:网站首页 › wsl 开机自动启动 › 在WSL启用ssh |
最好的Linux发行版是Windows10! 以下内容仅适用于Debian/Ubuntu. 安装并启动sshd首先, 需要在发行版中确认存在openssh-server这个包.和正常发行版不同的是, wsl中并没有使用systemd来启动系统.War, war never changes因此, 想要启动ssh-server必须通过/etc/init.d/ssh来实现. 注意此处要修改/etc/ssh/sshd_config. 其中的Port建议修改为大于1024的端口, PasswordAuthentication建议修改为yes. 测试/etc/init.d/ssh start, 成功后进行下一步. 开机自启动sshdwsl在执行第一个命令之前不会启动, 因此, 我们需要编写一个start_sshd.vbs脚本, 添加到计划任务里的开机启动事件. 脚本内容为: 123Set wshell=wscript.createobject("wscript.shell")wshell.run "C:\Windows\System32\wsl.exe sudo /etc/init.d/ssh start",0Set wshell=Nothing然而sudo命令需要输入密码才能启动, 为了bypass这一点, 需要修改sudo文件. 1sudo visudo添加 12# for wsl start sshd%sudo ALL=NOPASSWD: /etc/init.d/ssh start并保存. 完成后请务必重启系统测试. |
CopyRight 2018-2019 实验室设备网 版权所有 |